<?php 
session_cache_expire(999999999);
	if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
	$id_employee=$_SESSION['IDEmployee'];
	$id=$_GET['id'];
	include '../operations/connection.php';
	function getlang(){
		$lang = $_SESSION['lang'];
		
		if (empty($lang) || $lang == "EN") {
			$value = "../value/value_en.php";
		} else if($lang == "VN") {
			$value = "../value/value_vn.php";
		}
		else {
			$value = "../value/value_kr.php";
		}
		return $value;
	}
	$value = getlang();
	include($value);
	$lang = $_SESSION['lang'];
		//Get information of document
		
		$query = mysql_query("select a.Tile,a.Content,DATE_FORMAT(a.Timecreate, '%Y-%m-%d') as Timecreate,a.TripDate,a.purpose,a.Content2,a.Description,a.comment, e.Fullname,a.IDGroupApprove,a.IDStatus,a.IDEmployee,e.Position,dl.DepartmentName,a.IDTypeDoc
								from approvedoc a , employee e ,department_lang dl
								where a.IDApproveDoc = '$id' AND a.IDEmployee = e.IDEmployee AND e.IDDepartment=dl.IDDepartment AND dl.LangID='$lang';");
		
		while ($row = mysql_fetch_array($query))
		{
			$dcomment = $row['comment'];
			$dtitle = $row['Tile'];
			$ddescription = $row['Description'];
			$dtime = $row['Timecreate'];
			$duser = $row['Fullname'];
			$demployeeperforment = $row['EmployeePerforment'];
			$dtripdate = $row['TripDate'];
			$dlocation = $row['Location'];
			$dtotaltime = $row['TotalTime'];
			$didgroupapprover = $row['IDGroupApprove'];
			$dcontent = $row['Content'];
			$dcontent2 = $row['Content2'];
			$dpurpose = $row['purpose'];
			$didemployee = $row['IDEmployee'];
			$dstatus = $row['IDStatus'];
			$dsdepartment=$row['DepartmentName'];
			$dsposition=$row['Position'];
			$idtypedoc=$row['IDTypeDoc'];
		}
		$query2 = mysql_query("SELECT t.code FROM typedoc t WHERE t.IDTypeDoc=$idtypedoc");
        $result = mysql_fetch_assoc($query2);		
		$code= $result['code'];
		
		$query1 = mysql_query("SELECT l.IDStatus,l.DateApprove,e.Fullname,l.Description,l.IDEmployee ,dl.DepartmentName,e.Image
								FROM listapprove l , employee e ,department_lang dl
								WHERE l.IDGroupApprove= '$didgroupapprover' AND l.IDEmployee = e.IDEmployee  AND e.IDDepartment=dl.IDDepartment AND dl.LangID='$lang' ORDER BY l.Order ASC");

		
		
	?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" href="style/style.css" rel="stylesheet" />
<title>Print</title>
</head>

<body onload="window.print();">
	
<div class="print_report">
    	<div style="float: left; width:350px"><span id="form-caption"><?=$l_vacation_form?></span>
<table style="border-collapse:collapse" class="padd" width="100%">
            	<tr>
                	<th align="left" valign="top"><?=$l_employee?></th>
				  <td align="left" valign="top"><?=$duser?></td>
        		</tr>
                <tr>
                	<th align="left" valign="top"><?=$l_department?></th>
					<td align="left" valign="top"><?=$dsdepartment?></td>
                </tr> 
                <tr>
                	<th align="left" valign="top"><?=$l_created_date?></th>
					<td align="left" valign="top"><?=$dtime?></td>
        </tr>                
            </table>
        </div>
<div class="rcontent">
        	<table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse; float:right">
            	<tr>
                	<td width="45px" valign="middle" align="left">
                    	<img src="images/approver_en.png" alt="" />
                    </td>
                    <td>
                    	<ul class="list-approver" <?php if( mysql_num_rows( $query1)>=3){?> style="width: 320px" <?php }?> >
                    		<?php while ($row = mysql_fetch_array($query1)){
                    				$dnameapprover = $row[Fullname];
                    				$dnamedepartment = $row[DepartmentName];
                    		?>
							<li>
                            	<span class="approver-title"><?=$dnamedepartment?></span>
                            	<span class="approver-name"><?=$dnameapprover?></span>
                            	<?php if($row[Image]!="" && $row[IDStatus]==1){?>
                            		<div style="text-align: center;"><img src="../<?=$row[Image]?>" style="width: 70px; height: 65px; " alt="" /></div>
                            	<?php }else{?>
                            		<span class="approver-signature"></span>
                            	<?php }?>
                            </li>
                           <?php }?>
                      </ul>
                    </td>
                </tr>
            </table>
        </div>
        <br style="clear:both" />        
        <span class="separate"><img src="images/separate.png" alt="" /></span>
        <br />
        <span style="margin:10px 0; display:block">- <b><?=$l_title?> : </b><?=$dtitle?></span>
<span> - <b><?=$l_content?></b></span>
        <?=$dcontent?>  
        <?php 
        	mysql_close($connection);
        	
        	//$addressbrowser = "elitech.myapprove.com";
        	$addressbrowser = $_SERVER['SERVER_NAME'];
			$temp = explode(".", $addressbrowser);
			$connection = mysql_connect("1.234.53.52", "cam", "5678" ) ;
			//$connection = mysql_connect("localhost", "root", "root" ) ;
			mysql_select_db("elihan", $connection);
			mysql_query("set names 'utf8'");
			$selectdatabase = mysql_query("SELECT am.PartnerName from ac_eli_manager am where am.KeyName='$temp[0]' and am.`Status` = 2");
        	$result = mysql_fetch_assoc($selectdatabase);		
			$tencongty= $result['PartnerName'];
			
			mysql_close($connection);
        ?>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-top:16px">
            <tr>
            	<td align="left" width="50%"><?=$code?></td>
            	<td align="right" width="50%"><?=$tencongty?></td>
            </tr>
        </table>
</div>
</body>
</html>
